<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
  <style type="text/css">
  .layui-upload-img{
    /*width: 100px;*/
  }
  </style>
</head>
<body style="padding:15px;"> 
<form class="layui-form" action="">
  <div class="layui-form-item">
    <label class="layui-form-label">分类名称</label>
    <div class="layui-input-block">
      <input type="text" name="name" lay-verify="name" autocomplete="off" placeholder="请输入分类名称" class="layui-input" value="{$vo.name}">
    </div>
  </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否显示</label>
        <div class="layui-input-block">

            <input type="radio" name="status" lay-verify="status" autocomplete="off" title="显示"  class="layui-input" value="1" <if condition="$vo.status == 1">checked</if>>
            <input type="radio" name="status" lay-verify="status" autocomplete="off" title="隐藏"  class="layui-input" value="2" <if condition="$vo.status == 2">checked</if>>
        </div>
    </div>


  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit="" lay-filter="*">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>

<script id="pic" type="text/html">
  {{#  layui.each(d.pics, function(index, item){ }}
    <img class="layui-upload-img" src="{{ item }}" style="width: 100px; height: 100px;">
  {{#  }); }}
</script>  
<script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
var pics = [{$vo.pics_arr}];
layui.use(['form','upload', 'layedit', 'laytpl'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,$ = layui.jquery
  ,upload = layui.upload
  ,layedit = layui.layedit
  ,laytpl = layui.laytpl;

  var getTpl = pic.innerHTML
  ,view = document.getElementById('view');

  layedit.set({
    uploadImage: {
      url: '{:U("Home/Public/upload1")}'
    }
  });
  var contIdx = layedit.build("content", {
    tool: ["strong","italic","underline","del","|","left","center","right","|","face","image"]
  });
  

  //监听提交
  form.on('submit(*)', function(data){
    var post_data = data.field;
    post_data.content = layedit.getContent(contIdx);
    $.post('#', post_data, function(e) {
      layer.alert(e.info,function(index){
        if(e.status == 1){
          parent.location.reload();
        }else{
          layer.close(index);
        }
      });
    });
    return false;
  });
  
  laytpl(getTpl).render({pics:pics}, function(html){
    view.innerHTML = html;
  });
});
</script>

</body>
</html>